Show registration modal only when unregistered#1600
Show registration modal only when unregistered#1600gregorydlogan wants to merge 1 commit intoopencast:r/19.xfrom
Conversation
|
Use Run test server using develop.opencast.org as backend: Specify a different backend like stable.opencast.org: It may take a few seconds for the interface to spin up. |
|
This pull request is deployed at test.admin-interface.opencast.org/1600/2026-05-04_05-29-07/ . |
| // dispatch(fetchLatestToU()); | ||
| // dispatch(fetchIsUpToDate()); | ||
|
|
||
| const _getLatestToU = async () => { | ||
| await dispatch(fetchLatestToU()); | ||
| }; | ||
| const _getIsUpToDate = async () => { | ||
| await dispatch(fetchIsUpToDate()); | ||
| }; |
There was a problem hiding this comment.
This is going unused and should be removed.
| if (registration == null) { | ||
| dispatch(fetchRegistration()); | ||
| } |
There was a problem hiding this comment.
This will dispatch a redux action (and thus a fetch request) every time the component rerenders and registration is still null. This could potentially cause multiple fetch requests. To avoid this, we usually use a useEffect that only runs once on component mount for fetch requests. (see the useEffect in e.g. SeriesDetails.tsx).
If you need to monitor the state of the action, you would usually add a variable to the redux state that tracks the action state (LOADING, SUCCEEDED, FAILED what have you). Then track the action state in your component via a selector and use a useEffect to respond properly.
And if you don't actually need all that redux boilerplate, you could also do the fetch requesting and state tracking here with useEffect and useState.
| import { WritableDraft } from "immer"; | ||
| import { createAppAsyncThunk } from "../createAsyncThunkWithTypes"; | ||
|
|
||
| export type Registration = { |
There was a problem hiding this comment.
Since all this PR really does is checking if ´/admin-ng/adopter/registration` returns null or not, creating a whole redux state is complete overkill. If you'll need this for some other PR, would it not be better to add it then?
This PR only shows the registraiton modal when the adopter has not already registered.
This PR contains a few extra bits that haven't been turned on yet - notably the warning bell stuff for when the core can't reach the registration server.
Fixed #1516